home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1997 #1 / Amiga Plus CD - 1997 - No. 01.iso / pd / programmierung / proasm / routines / gtfsupport_reb.r < prev    next >
Text File  |  1993-10-18  |  10KB  |  394 lines

  1. ****************************************************************************
  2. *                                        *
  3. *                     ****   gtfsupport REB    ****                *
  4. *                                         *
  5. *              Some additional GTFace (© Stefan Walter) calls            *
  6. *                                         *
  7. *    Author        René Eberhard                        *
  8. *    Version        0.3                            *
  9. *    Last Revision    Monday 18-Oct-93 21:47:53                *
  10. *    Identifier    gtfreb_defined                        *
  11. *       Prefix        gtfreb_ (GTFace REB support)                *
  12. *                                ¯¯¯    ¯¯¯                         *
  13. *-----------------------------[ UPDATES ]----------------------------------*
  14. *                                        *
  15. *    -REB!    17-Oct-93    Start this Project               *
  16. *                                        *
  17. ****************************************************************************
  18. *---------------------------[ Functions ]----------------------------------*
  19. *                                        *
  20. * - MoveLVEntryUp, MoveLVEntryDown, LVAlphaSort                    *
  21. *                                        *
  22. *---------------------------[ COMMENT ]------------------------------------*
  23. *                                            *
  24. ****************************************************************************
  25. ;---------------------------------------------------------------------------
  26.     IFND    gtfreb_defined
  27. gtfreb_defined    SET    1
  28.  
  29.  
  30. ;---------------[ Some includes ]-------------------------------------------
  31.  
  32.         
  33. ;---------------------------------------------------------------------------
  34.  
  35.     IFND    USE_NEWROUTINES
  36.     NEED_    MoveLVEntryUp
  37.     NEED_    MoveLVEntryDown
  38.     NEED_    LVAlphaSort
  39.     ENDIF
  40.         
  41. ;---------------------------------------------------------------------------
  42. ****************************************************************************
  43. *                                        *
  44. * NAME    : MoveLVEntryUp                            *
  45. *                                        *
  46. * SYNOPSIS:                                     *
  47. *       Result = MoveLVEntryUp (Entry, Gadget, List, WindowKey)            *
  48. *       D0.W                    D0.W   A0.L    A1.L  A2.L            *
  49. *                                        *
  50. * FUNCTION: Move an entry one step up                        *
  51. *                                        *
  52. * RESULT  : Actual entry or ERROR (D0.L = -1)                    *
  53. *                ^^^^^^^^^^^^^^^^^                    *
  54. * COMMENT : Entry e.g from gfw_msgcode                        *
  55. *                                        *
  56. ****************************************************************************
  57.     IFD    xxx_MoveLVEntryUp
  58.  
  59. MoveLVEntryUp:
  60.  
  61.     NEED_    gtfreb_LV_Top        ;Need this subroutine
  62.  
  63.     PUSHM.L    d1-a6
  64.  
  65.     link    a5,#gtfreb_LV_SIZEOF
  66.  
  67.     move.w    d0,gtfreb_LV_Entry(a5)    ;Store Entry
  68.     beq.s    \Rtn            ;Top entry -> can't move up
  69.     bmi.s    \Fail
  70.  
  71.     move.l    a0,gtfreb_LV_Gadget(a5)    ;Store gadget
  72.     move.l    a1,gtfreb_LV_List(a5)    ;Store listpointer
  73.     move.l    a2,gtfreb_LV_WdKey(a5)    ;Store WindowKey
  74.  
  75. ;===============[ List handling ]===========================================
  76.  
  77.     move.l    AbsExecBase,a6
  78.     move.w    gtfreb_LV_Entry(a5),d7    ;Search given node
  79.  
  80. \SNode:    move.l    (a1),a1            ;Get nodepointer
  81.     tst.l    (a1)
  82.     beq.s    \Fail            ;End of node -> Fail
  83.     dbf    d7,\SNode
  84.     
  85.     move.l    a1,a4            ;Store node for Insert()
  86.     move.l    LN_PRED(a4),a2        ;Pointer to previous
  87.     tst.l    (a2)
  88.     beq.s    \Fail            ;End of node -> Fail
  89.     move.l    LN_PRED(a2),a2        ;And again
  90.  
  91. ;---------------[ Remove lables and node ]----------------------------------
  92.  
  93.     APUSHM
  94.     move.l    gtfreb_LV_Gadget(a5),a0
  95.     move.l    gtfreb_LV_WdKey(a5),a2    ;Store WindowKey
  96.     CALL_    RemoveLVLabels        ;Remove LV lables
  97.     APOPM
  98.  
  99.     JSRLIB_    Remove            ;Remove node from list
  100.  
  101. ;---------------[ ReInsert node ]-------------------------------------------
  102.  
  103.     move.l    gtfreb_LV_List(a5),a0    ;listpointer
  104.     move.l    a4,a1            ;Node
  105.     JSRLIB_    Insert            ;A2.L from above    
  106.  
  107. ;---------------[ Handle visible aera ]-------------------------------------
  108.  
  109. \Set:    subq.w    #1,gtfreb_LV_Entry(a5)    ;Sub actual entry
  110.     move.w    gtfreb_LV_Entry(a5),d0
  111.     move.l    gtfreb_LV_List(a5),a0    ;ReSet lables
  112.     CALL_    gtfreb_LVSelect
  113.  
  114. ;---------------[ Exit ]----------------------------------------------------
  115.  
  116.     move.w    gtfreb_LV_Entry(a5),d0    ;Result code
  117.     bra.s    \Rtn
  118.  
  119. \Fail:    moveq    #-1,d0
  120.  
  121. \Rtn:    unlk    a5
  122.     POPM.L    d1-a6
  123.     rts
  124.  
  125.     ENDC
  126. ;---------------------------------------------------------------------------
  127. ****************************************************************************
  128. *                                        *
  129. * NAME    : MoveLVEntryDown                            *
  130. *                                        *
  131. * SYNOPSIS:                                     *
  132. *       Result = MoveLVEntryDown (Entry, Gadget, List, WindowKey)        *
  133. *       D0.W                      D0.W   A0.L    A1.L  A2.L            *
  134. *                                        *
  135. * FUNCTION: Move an entry one step down                        *
  136. *                                        *
  137. * RESULT  : Actual entry                             *
  138. *                                         *
  139. * COMMENT : Entry e.g from gfw_msgcode                        *
  140. *                                        *
  141. ****************************************************************************
  142.     IFD    xxx_MoveLVEntryDown
  143.  
  144. MoveLVEntryDown:
  145.  
  146.     NEED_    gtfreb_LV_Top        ;Need this subroutine
  147.  
  148.     PUSHM.L    d1-a6
  149.  
  150.     link    a5,#gtfreb_LV_SIZEOF
  151.  
  152.     move.w    d0,gtfreb_LV_Entry(a5)    ;Store Entry
  153.     bmi.s    \Rtn            ;Fail result as entry
  154.  
  155.     move.l    a0,gtfreb_LV_Gadget(a5)    ;Store gadget
  156.     move.l    a1,gtfreb_LV_List(a5)    ;Store listpointer
  157.     move.l    a2,gtfreb_LV_WdKey(a5)    ;Store WindowKey
  158.  
  159. ;===============[ List handling ]===========================================
  160.  
  161.     move.l    AbsExecBase,a6
  162.  
  163.     move.w    gtfreb_LV_Entry(a5),d7    ;Search given node
  164.  
  165. \SNode:    move.l    (a1),a1            ;Get nodepointer
  166.     tst.l    (a1)
  167.     beq.s    \Last
  168.     dbf    d7,\SNode
  169.     
  170.     move.l    a1,a4            ;Store node for Insert()
  171.     move.l    LN_SUCC(a4),a2        ;Pointer to successor
  172.     tst.l    (a2)            ;Actual entry IS the last entry
  173.     beq.s    \Last
  174.  
  175. ;---------------[ Remove lables and node ]----------------------------------
  176.  
  177.     APUSHM
  178.     move.l    gtfreb_LV_Gadget(a5),a0
  179.     move.l    gtfreb_LV_WdKey(a5),a2    ;Store WindowKey
  180.     CALL_    RemoveLVLabels        ;Remove LV lables
  181.     APOPM
  182.  
  183.     JSRLIB_    Remove            ;Remove node from list ; A1.Ll from above
  184.  
  185. ;---------------[ ReInsert node ]-------------------------------------------
  186.  
  187. \ReIn:    move.l    gtfreb_LV_List(a5),d0    ;listpointer
  188.     move.l    a4,a1            ;Node
  189.     JSRLIB_    Insert            ;A2.L from above    
  190.  
  191. ;---------------[ Handle visible aera ]-------------------------------------
  192.  
  193. \Set:    addq.w    #1,gtfreb_LV_Entry(a5)    ;Add actual entry
  194.     move.w    gtfreb_LV_Entry(a5),d0
  195.     move.l    gtfreb_LV_List(a5),a0
  196.     CALL_    gtfreb_LVSelect
  197.  
  198.  
  199. \Last:    move.w    gtfreb_LV_Entry(a5),d0    ;Result code
  200.  
  201. \Rtn:    unlk    a5
  202.     POPM.L    d1-a6
  203.     rts
  204.  
  205.     ENDC
  206. ;---------------------------------------------------------------------------
  207. ****************************************************************************
  208. *                                        *
  209. * NAME    : LVAlphaSort                                *
  210. *                                        *
  211. * SYNOPSIS:                                     *
  212. *       Result = LVAlphaSort (Gadget, List, WindowKey)                *
  213. *       D0.L                  A0.L    A1.L  A2.L                *
  214. *                                        *
  215. * FUNCTION: Sorts a list in alphabetical order                    *
  216. *                                        *
  217. * RESULT  : TRUE / FALSE                             *
  218. *                                         *
  219. ****************************************************************************
  220.     IFD    xxx_LVAlphaSort
  221.  
  222.     NEED_    gtfreb_LV_Top        ;Need this subroutine
  223.     NEED_    gtfreb_SwapNode        ;Need this subroutine
  224.  
  225. LVAlphaSort:
  226.  
  227.     PUSHM.L    d1-a6
  228.  
  229.     link    a5,#gtfreb_LV_SIZEOF
  230.  
  231.     move.l    a0,gtfreb_LV_Gadget(a5)    ;Store gadget
  232.     move.l    a1,gtfreb_LV_List(a5)    ;Store listpointer
  233.     move.l    a2,gtfreb_LV_WdKey(a5)    ;Store WindowKey
  234.         
  235.     move.l    (a1),a3            ;Pointer to first node
  236.  
  237. ;---------------[ Remove lables and node ]----------------------------------
  238.  
  239.     move.l    gtfreb_LV_Gadget(a5),a0
  240.     move.l    gtfreb_LV_WdKey(a5),a2    ;Store WindowKey
  241.     CALL_    RemoveLVLabels        ;Remove LV lables
  242.  
  243. ;---------------[ Get two nodes ]-------------------------------------------
  244.  
  245.     moveq    #0,d7            ;Clr flag for loop
  246.  
  247.     move.l    UtilityBase,a6
  248.  
  249. \Loop:    move.l    LN_SUCC(a3),a4        ;Copy next node into A4.L
  250.     tst.l    (a4)            
  251.     beq.s    \Last            ;It was the last entry
  252.  
  253.     move.l    LN_NAME(a3),a0        ;Compare both strings
  254.     move.l    LN_NAME(a4),a1
  255.     JSRLIB_    Stricmp
  256.     tst.l    d0
  257.     bpl.s    \Swap
  258.  
  259.     move.l    LN_SUCC(a3),a3
  260.     tst.l    (a3)
  261.     beq.s    \Last
  262.     bra    \Loop
  263.  
  264. ;---------------[ Last ]----------------------------------------------------
  265.  
  266. \Last:    tst.l    d7
  267.     beq.s    \Rtn
  268.     moveq    #0,d7            ;Clr flag for loop
  269.  
  270.     move.l    gtfreb_LV_List(a5),a3
  271.  
  272.     move.l    LN_SUCC(a3),a3
  273.     tst.l    (a3)
  274.     beq.s    \Rtn
  275.     bra    \Loop
  276.  
  277. \Rtn:    moveq    #0,d0
  278.     move.l    gtfreb_LV_List(a5),a0
  279.     CALL_    gtfreb_LVSelect
  280.  
  281.     unlk    a5
  282.     POPM.L    d1-a6
  283.     rts
  284.         
  285. ;===============[ Swap ]====================================================
  286.  
  287. \Swap:    moveq    #-1,d7            ;Set flag for changeing
  288.  
  289.     move.l    gtfreb_LV_List(a5),a0    ;Listpointer
  290.     move.l    a3,a1            ;Node
  291.     CALL_    gtfreb_SwapNode
  292.  
  293.     move.l    LN_SUCC(a3),a3
  294.     tst.l    (a3)
  295.     beq.s    \Last
  296.     bra.s    \Loop
  297.  
  298.     ENDC
  299. ;---------------------------------------------------------------------------
  300. ****************************************************************************
  301. *                                        *
  302. * SUBROUTINE : gtfreb_LVSelect                            *
  303. *                                        *
  304. * SYNOPSIS:                                     *
  305. *       gtfreb_LVSelect (TopEntry,Lables)                    *
  306. *                        D0.W       A0.L                        *
  307. *                                        *
  308. * FUNCTION: Select entry                            *
  309. *                                        *
  310. ****************************************************************************
  311.     IFD    xxx_gtfreb_LVSelect
  312.  
  313. gtfreb_LVSelect:
  314.     APUSHM
  315.  
  316.     lea    \gtfreb_Select_TagList(PC),a3
  317.  
  318.     move.l    a0,4(a3)            ;Set lables
  319.  
  320.     moveq    #0,d1
  321.     move.w    d0,d1
  322.     move.l    d1,12(a3)            ;Put in tag_data
  323.     move.l    d1,20(a3)
  324.  
  325. ;---------------[ SetGadgetAttrs ]------------------------------------------
  326.  
  327. \NoTag:    move.l    gtf_gadtoolsbase(PC),a6
  328.     move.l    gtfreb_LV_Gadget(a5),a0
  329.     move.l    gtfreb_LV_WdKey(a5),a1
  330.     move.l    gfw_window(a1),a1
  331.     suba.l    a2,a2
  332.     JSRLIB_    GT_SetGadgetAttrsA        ;A3.L from above
  333.  
  334. \Rtn:    APOPM
  335.     rts
  336.  
  337. \gtfreb_Select_TagList:    dc.l    GTLV_Labels,0
  338.             dc.l    GTLV_Top,0
  339.             dc.l    GTLV_Selected,0
  340.             dc.l    TAG_DONE
  341.  
  342.     ENDC
  343. ;---------------------------------------------------------------------------
  344. ****************************************************************************
  345. *                                        *
  346. * SUBROUTINE : gtfreb_SwapNode                            *
  347. *                                        *
  348. * SYNOPSIS:                                     *
  349. *       gtfreb_SwapNode (List, Node)                        *
  350. *                        A0.L  A1.L                         *
  351. *                                        *
  352. * FUNCTION: Swaps the actual node and its successor                *
  353. *                                        *
  354. ****************************************************************************
  355.     IFD    xxx_gtfreb_SwapNode
  356. gtfreb_SwapNode:
  357.  
  358.     APUSHM
  359.     move.l    AbsExecBase,a6
  360.  
  361.     move.l    LN_SUCC(a1),a2        ;Pointer to successor
  362.     tst.l    (a2)            ;Is there a next entry
  363.     beq.s    \Rtn            ;No -> Don't swap -> Exit
  364.  
  365.     PUSHM.L    a0-a2
  366.     JSRLIB_    Remove            ;A1.L from above
  367.     POPM.L    a0-a2
  368.  
  369.     JSRLIB_    Insert
  370.  
  371. \Rtn:    APOPM
  372.     rts
  373.  
  374.     ENDC
  375. ;---------------------------------------------------------------------------
  376. ****************************************************************************
  377. *                                        *
  378. *                                        *
  379. * DATA                                        *
  380. *                                        *
  381. *                                        *
  382. ****************************************************************************
  383.  
  384.             FORESET
  385. gtfreb_LV_List:        FO.L    1
  386. gtfreb_LV_Entry:    FO.W    1
  387. gtfreb_LV_Gadget:    FO.L    1
  388. gtfreb_LV_WdKey:    FO.L    1
  389. gtfreb_LV_SIZEOF    FOVAL
  390.  
  391. ;---------------------------------------------------------------------------
  392.         ENDC
  393. ;---------------------------------------------------------------------------
  394.